package com.mc.net;

import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;

public class HttpRequest {
	
	/**
	 * 使用get方式发起请求 返回请求结果
	 * @param url
	 */
	public static void sendGet(String url){
		
		
		try {
			URL realUrl = new URL(url);
			URLConnection conn = realUrl.openConnection();
			conn.connect();
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
			String line="";
			while((line=br.readLine())!=null){
				System.out.println(line);
			}
			br.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args){
		String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx045752ac3c8bc6e5&secret=71a9a63a247d6ceeee283477e0783d24";
		HttpRequest.sendGet(url);
	}
}
